#include<iostream>
#include "romfile.h"
#include "mem.h"
#include "cpu.h"
using namespace std;

int main(int argc, char **argv) {
    string * filename;
    romfile * rf;
    if(argc==1) {
        cout<<"Usage:\t"<<argv[0]<<" <filename>"<<endl;
        return 1;
    }
    else if(argc==2) {
        filename=new string(argv[1]);
        cout<<"Attempting to load file \""<<*filename<<"\"."<<endl;
        rf=new romfile(*filename);
    }
    if(!(rf->isvalid())) {
        cout<<*filename<<" wasn't loaded correctly. Aborting."<<endl;
        return 1;
    } 
    mem * m = new mem(rf);
    cpu *c = new cpu(m,0x100);
    c->calc_frame();
    return 0;
}
